﻿using Cxuu.Models;
using Cxuu.Service;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using PetaPoco;
using System.Threading.Tasks;

namespace Cxuu.Web.Admin
{
    [Area("Admin")]
    [Authorize]
    public class LogController : Base
    {
        private readonly LogService _logService;
        public LogController(LogService logService)
        {
            _logService = logService;
        }


        [HttpGet]
        public async Task<IActionResult> IndexAsync(int page = 1, int limit = 15, int json = 0)
        {
            if (json == 1)
            {
                ViewAdminUser adminUser = await UserClaims();
                int adminUid = adminUser.Gid != 1 ? adminUser.Id : 0;//超级管理员显示全部数据
                Page<ViewLogSql> list = await _logService.GetSqlListAsync(page, limit, adminUid);
                return Json(new { code = 0, data = list.Items, count = list.TotalItems });
            }
            return View();
        }


    }
}
